﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace netCoreStudy.Extensions
{
	/// <summary>
	/// ef 服务 设置
	/// </summary>
	public static class DbSetup
	{
		public static void AddDbSetup(this IServiceCollection services,
			IConfiguration configuration)
		{
			if (services == null) throw new ArgumentNullException(nameof(services));


			services.AddDbContext<ApiDbContext>(option =>
			{
				option.EnableSensitiveDataLogging(true); // 敏感数据加密
				// option.UseSqlite("Data Source=NetCoreStudy.Db");
				option.UseSqlite("Data Source=NetCoreStudy.Db");
				//option.UseMySQL(configuration.GetConnectionString("DefaultConnection"));
			});
		}
	}
}